<!DOCTYPE html> {% load static %}
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="Dashboard">
    <meta name="keyword" content="Dashboard, Bootstrap, Admin, Template, Theme, Responsive, Fluid, Retina">
    <title>我的信息</title>
    <!-- Bootstrap core CSS -->
    <link href="{% static 'lib/bootstrap/css/bootstrap.min.css' %}" rel="stylesheet">
    <!--external css-->
    <link href="{% static 'lib/font-awesome/css/font-awesome.css' %}" rel="stylesheet" />
    <link rel="stylesheet" type="text/css" href="{% static 'lib/gritter/css/jquery.gritter.css' %}" />
    <!-- Custom styles for this template -->
    <link href="{% static 'css/style.css' %}" rel="stylesheet">
    <link href="{% static 'css/style-responsive.css' %}" rel="stylesheet">


</head>

<body>
    <section id="container">
        <!-- **********************************************************************************************************************************************************
        TOP BAR CONTENT & NOTIFICATIONS
        *********************************************************************************************************************************************************** -->
        <!--header start-->
        <header class="header black-bg">
            <div class="sidebar-toggle-box">
                <div class="fa fa-bars tooltips" data-placement="right" data-original-title="Toggle Navigation"></div>
            </div>
            <!--logo start-->
            <a href="index.html" class="logo"><b>奖助学金评定<span>系统</span></b></a>
            <!--logo end-->
            <div class="nav notify-row" id="top_menu">
                <!--  notification start -->
                <ul class="nav top-menu">
                    <!-- inbox dropdown start-->
                    <li id="header_inbox_bar" class="dropdown">
                        <a data-toggle="dropdown" class="dropdown-toggle" href="index.html#">
                            <i class="fa fa-envelope-o"></i>
                            {% if no_read_message_count != 0 %} <span class="badge bg-theme">{{ no_read_message_count }}</span>{% endif %}
                        </a>
                        <ul class="dropdown-menu extended inbox">
                            <div class="notify-arrow notify-arrow-green"></div>
                            <li>
                                <p class="green">你有{{ no_read_message_count }} 条信息未读</p>
                            </li>
                            {% for no_read_message in no_read_message_list %}
                            <li>
                                <a href="{% url 'dataManagement:messageShow' no_read_message.id %}">
                                    <span class="photo"><i class="fa fa-envelope-o"></i></span>
                                    <span class="subject">
                    <span class="from">来自{{ no_read_message.from_user }}</span>
                                    <span class="time">{{ no_read_message.send_time }}</span>
                                    </span>
                                    <span class="message">
                      {{ no_read_message.text | truncatechars:17 }}...
                    </span>
                                </a>
                            </li>
                            {% empty %} 暂无消息 {% endfor %}
                        </ul>
                    </li>
                    <!-- inbox dropdown end -->
                </ul>
                <!--  notification end -->
            </div>
            <div class="top-menu">
                <ul class="nav pull-right top-menu">
                    <li><a class="logout" href="{% url 'MyUser:logout' %}">退出</a></li>
                </ul>
            </div>
        </header>
        <!--header end-->
        <!-- **********************************************************************************************************************************************************
        MAIN SIDEBAR MENU
        *********************************************************************************************************************************************************** -->
        <!--sidebar start-->
        <aside>
            <div id="sidebar" class="nav-collapse ">
                <!-- sidebar menu start-->
                <ul class="sidebar-menu" id="nav-accordion">
                    <h5 class="centered">{% if request.user.name %}你好!&nbsp; {{ request.user.name }}{% else %} 请完善个人信息! {% endif %}</h5>
                    <li class="mt">
                        <a href="{% url 'dataManagement:index' %}">
                            <i class="fa fa-dashboard"></i>
                            <span>首页</span>
                        </a>
                    </li>
                    <li class="sub-menu">
                        <a class="active" href="javascript:;">
                            <i class="fa fa-desktop"></i>
                            <span>设置</span>
                        </a>
                        <ul class="sub">
                            <li class="active"><a href="{% url 'dataManagement:myinfo' %}">我的信息</a></li>
                            <li><a href="{% url 'dataManagement:setPassword' %}">修改密码</a></li>
                        </ul>
                    </li>
                    <li class="sub-menu">
                        <a href="javascript:;">
                            <i class="fa fa-cogs"></i>
                            <span>评审信息</span>
                        </a>
                        {% if request.user.identity == "学生" %}
                        <ul class="sub">
                            <li><a href="{% url 'dataManagement:requestLog' %}">申请记录</a></li>
                        </ul>
                        {% elif request.user.identity == "老师" %}
                        <ul class="sub">
                            <li><a href="{% url 'dataManagement:meetingList' %}">我的学生</a></li>
                            <!--                <li><a href="{% url 'dataManagement:juryGradeMeetingList' %}">我是评委</a></li>-->
                        </ul>
                        {% elif request.user.identity == "评委" %}
                        <ul class="sub">
                            <li><a href="{% url 'dataManagement:juryGradeMeetingList' %}">我是评委</a></li>
                        </ul>
                        {% endif %}
                    </li>
                    <li>
                        <a href="{% url 'dataManagement:messageIndex' %}?num=1&&choice=1">
                            <i class="fa fa-envelope"></i>
                            <span>消息 </span>
                            <span class="label label-theme pull-right mail-info">{{ no_read_message_count }}</span>
                        </a>
                    </li>
                </ul>
                <!-- sidebar menu end-->
            </div>
        </aside>
        <!--sidebar end-->
        <!-- **********************************************************************************************************************************************************
        MAIN CONTENT
        *********************************************************************************************************************************************************** -->
        <!--main content start-->
        <section id="main-content">
            <section class="wrapper">
                <div class="row">
                    <div class="col-lg-6 col-md-6 col-sm-12 col-md-offset-3">
                        <!--  BASIC PROGRESS BARS -->
                        <div class="showback">
                            <h4><i class="fa fa-angle-right"></i> 我的信息</h4>
                            <div class="myinfo-content">
                                <form>
                                    <div class="form-group">
                                        <label for="exampleInputUserName">用户名/学号</label>
                                        <input type="email" class="form-control" id="exampleInputUserName" readonly value="{{ user_obj.username }}">
                                    </div>
                                    <div class="form-group">
                                        <label for="exampleInputName">姓名</label>
                                        <input type="text" class="form-control" id="exampleInputName" value="{{ user_obj.name | default_if_none:'' }}">
                                    </div>
                                    <div class="form-group">
                                        <label for="exampleInputEmail">邮箱</label>
                                        <input type="email" class="form-control" id="exampleInputEmail" value="{{ user_obj.email | default_if_none:'' }}">
                                        <span class="EmailError" style="color: #FF6347;"></span>
                                    </div>
                                    <div class="form-group">
                                        <label for="exampleInputPhone">电话</label>
                                        <input type="text" class="form-control" id="exampleInputPhone" value="{{ user_obj.phone | default_if_none:'' }}">
                                        <span class="phoneError" style="color: #FF6347;"></span>
                                    </div>
                                    {% if user_info %} {% if request.user.identity == "学生" %}
                                    <div class="form-group">
                                        <label for="exampleInputSex">性别</label>
                                        <!--                      <input type="text" class="form-control" id="exampleInputSex" placeholder="{{ user_info.sex }}">-->
                                        <select class="form-control" id="exampleInputSex">
                        <option>请选择</option>
                        <option value="男" {% if user_info.sex == "男" %} selected {% endif %}>男</option>
                        <option value="女" {% if user_info.sex == "女" %} selected {% endif %}>女</option>
                      </select>
                                    </div>
                                    <div class="form-group">
                                        <label for="exampleInputJoin">入学年份</label>
                                        <input type="text" class="form-control" id="exampleInputJoin" readonly value="{{ user_info.startDate | date:'Y/m' }}">
                                    </div>
                                    <div class="form-group">
                                        <label for="exampleInputTutor">导师</label>
                                        <input type="text" class="form-control" id="exampleInputTutor" readonly value="{{ user_info.tutor }}">
                                    </div>
                                    <div class="form-group">
                                        <label for="exampleInputCET4">四级使用次数</label>
                                        <input type="text" class="form-control" id="exampleInputCET4" readonly value="{{ user_info.CET4Count }}">
                                    </div>
                                    <div class="form-group">
                                        <label for="exampleInputCET6">六级使用次数</label>
                                        <input type="text" class="form-control" id="exampleInputCET6" readonly value="{{ user_info.CET6Count }}">
                                    </div>
                                    <div class="form-group">
                                        <label for="exampleInputAdmissionstatus">入学方式</label>
                                        <input type="text" class="form-control" id="exampleInputAdmissionstatus" readonly value="{{ user_info.admissionstatus }}">
                                    </div>
                                    {% endif %} {% endif %}
                                    <div class="form-group">
                                        <label for="exampleInputIdentity">身份</label>
                                        <input type="text" class="form-control" id="exampleInputIdentity" readonly value="{{ user_obj.identity }}">
                                    </div>
                                    <div style="text-align: center">
                                        <!--                    <span class="error" style="color: #FF6347;" ></span>-->
                                        <!--                    </br>-->
                                        <button class="btn btn-default save-info">修改</button>
                                    </div>
                                </form>
                            </div>
                        </div>
                        <!--/showback -->
                    </div>
                </div>
                <!--/ row -->
            </section>
            <!-- /wrapper -->
        </section>
        <!-- /MAIN CONTENT -->
        <!--main content end-->
    </section>
    <!-- js placed at the end of the document so the pages load faster -->
    <script src="{% static 'lib/jquery/jquery.min.js' %}"></script>

    <script src="{% static 'lib/bootstrap/js/bootstrap.min.js' %}"></script>
    <script class="include" type="text/javascript" src="{% static 'lib/jquery.dcjqaccordion.2.7.js' %}"></script>
    <script src="{% static 'lib/jquery.scrollTo.min.js' %}"></script>
    <script src="{% static 'lib/jquery.nicescroll.js' %}" type="text/javascript"></script>
    <!--common script for all pages-->
    <script src="{% static 'lib/common-scripts.js' %}"></script>
    <!--script for this page-->
    <script type="text/javascript" src="{% static 'lib/gritter/js/jquery.gritter.js' %}"></script>
    <script type="text/javascript" src="{% static 'lib/gritter-conf.js' %}"></script>
    <script>
        $(".save-info").click(function() {
                var r = confirm("确认修改吗?");
                if (r == true) {
                    var name = $.trim($("#exampleInputName").val());
                    var email = $.trim($("#exampleInputEmail").val());
                    var phone = $.trim($("#exampleInputPhone").val());
                    var sex = $.trim($("#exampleInputSex").val());
                    var identity = $.trim($("#exampleInputIdentity").val());
                    // email
                    var reg1 = /^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/;
                    // phone
                    var pattern = /^1[34578]\d{9}$/;
                    if (reg1.test(email) == true) {
                        if (pattern.test(phone) == false) {
                            $(".phoneError").text("请填写正确号码!")
                            return false;
                        } else {
                            $.post("{% url 'dataManagement:myinfo' %}", {
                                "name": name,
                                "email": email,
                                "phone": phone,
                                "sex": sex,
                                "identity": identity,
                                csrfmiddlewaretoken: '{{ csrf_token }}'
                            }, function(data) {
                                alert(data.status);
                            })
                        }
                    } else {
                        $(".EmailError").text("请填写正确的邮箱!");
                        return false;
                    }
                } else {
                    x = "您按了取消！";
                }
            })
            // $("#exampleInputPhone").bind("changge", function () {
            //   // phone
            //         var pattern = /^1[34578]\d{9}$/;
            //         var phone = $("#exampleInputPhone").val()
            //         if(pattern.test($.trim(phone)) == false ){
            //             $()
            //         }
            // })
    </script>
</body>

</html>